package com.example.module_message.ui

import androidx.lifecycle.MutableLiveData
import com.example.lib_common.base.BaseViewModel
import com.example.module_message.model.MessageEntity
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class MessageViewModel @Inject constructor(private val repository :MessageRepository):BaseViewModel(){
   private val messageList by lazy {
       MutableLiveData<List<MessageEntity>>()
   }
    val messageListLiveData get() = messageList
    fun getMessageList(accessId:String,userId:Int){
        execute(
            action = repository.getMessageList(accessId, userId),
            onError = {
                messageList.value = null
            },
            onFinish = {
                messageList.value = it.data
            }
        )
    }

}